# Maintainer: Taozuhong <taozuhong@gmail.com>

_realname=libadwaita
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=1.3.5
pkgrel=1
pkgdesc="Building blocks for modern GNOME applications (mingw-w64)"
url="https://gitlab.gnome.org/GNOME/libadwaita"
license=("spdx:LGPL-2.1-or-later")
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32' 'clangarm64')
depends=("${MINGW_PACKAGE_PREFIX}-glib2"
         "${MINGW_PACKAGE_PREFIX}-gtk4")
makedepends=("${MINGW_PACKAGE_PREFIX}-meson"
             "${MINGW_PACKAGE_PREFIX}-pkgconf"
             "${MINGW_PACKAGE_PREFIX}-vala"
             "${MINGW_PACKAGE_PREFIX}-sassc"
             "${MINGW_PACKAGE_PREFIX}-cc"
             "${MINGW_PACKAGE_PREFIX}-gobject-introspection")
source=("https://download.gnome.org/sources/libadwaita/${pkgver:0:3}/libadwaita-${pkgver}.tar.xz"
        0002-meson-fix-static-lib-install.patch)
sha256sums=('faa3ff0f36db18ab4942f4904a295293ccb144755b9bb85131393f201926b586'
            '4ed2c6b09fcb5b15823819dbefa348f179083d2683ee760253dd7b3297821bea')

prepare() {
  cd "${srcdir}/${_realname}-${pkgver}"

  patch -p1 -i "${srcdir}/0002-meson-fix-static-lib-install.patch"
}

build() {
  mkdir "${srcdir}"/build-${MSYSTEM} && cd "${srcdir}"/build-${MSYSTEM}

  MSYS2_ARG_CONV_EXCL="--prefix=" \
  ${MINGW_PREFIX}/bin/meson.exe setup \
    --prefix="${MINGW_PREFIX}" \
    --buildtype=plain \
    --default-library=both \
    --wrap-mode=nodownload \
    -Dexamples=true \
    -Dgtk_doc=false \
    -Dtests=false \
    ../${_realname}-${pkgver}

  ${MINGW_PREFIX}/bin/meson.exe compile
}

package() {
  cd "${srcdir}"/build-${MSYSTEM}
  ${MINGW_PREFIX}/bin/meson.exe install --destdir="${pkgdir}"
  install -Dm644 "${srcdir}/${_realname}-${pkgver}/COPYING" "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/COPYING"
}
